<template>
    <div>
        富文本编辑器
        <QuillEditor 
        v-model:content="cont" 
        content-type="html" 
        @textChange="handelChange"
        theme="snow"
        :toolbar="toolbarOptions"
        />
        <n-button type="primary" size="medium"  @click="handelRichText">提取并且使用富文本内容</n-button>
        <div v-html="cont"></div>
        <n-button type="primary" size="medium" @click="copy">点击复制文本</n-button>
        
        <div>{{ words }}</div>
    </div>
</template>

<script setup>
import { QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css';
import '@vueup/vue-quill/dist/vue-quill.bubble.css';
import { ref } from 'vue';
const cont = ref('')
const handelRichText = () => {
    console.log(cont);
}
const handelChange=()=>{
    console.log('富文本内容发生了改变');
    
}
const toolbarOptions = [
  ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
  ['blockquote', 'code-block'],
  ['link', 'image', 'video', 'formula'],

  [{ 'header': 1 }, { 'header': 2 }],               // custom button values
  [{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
  [{ 'script': 'sub'}, { 'script': 'super' }],      // superscript/subscript
  [{ 'indent': '-1'}, { 'indent': '+1' }],          // outdent/indent
  [{ 'direction': 'rtl' }],                         // text direction

  [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
  [{ 'header': [1, 2, 3, 4, 5, 6, false] }],

  [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
  [{ 'font': [] }],
  [{ 'align': [] }],

  ['clean']                                         // remove formatting button
];
const words = ref('')
for(let i = 15000;i<20000;i++){
    words.value += String.fromCharCode(i)
}

import { useClipboard } from '@vueuse/core'

const source = ref('Hello')
const { text, copy, copied, isSupported } = useClipboard({ source })
</script>

<style lang="scss" scoped>

</style>